# -*- coding: utf-8 -*-
# @Date    : 2015-06-21 15:50:35
# @Author  : Your Name (you@example.org)
# @Link    : http://example.org
# @Version : $Id$


from lib.tornado_routes import route
from web.handler import BaseHandler
from tornado import gen
from tornado.web import asynchronous


@route(r'/admin/login/?', name='')
class IndexHandler(BaseHandler):
    @asynchronous
    @gen.coroutine
    def get(self):
        self.render("admin/login.html",)

    @asynchronous
    @gen.coroutine
    def post(self):
        # TODO 增加数据库获取用户信息，并放入session
        self.session['user'] = 'shitao'
        self.session['pwd'] = '123456'
        self.redirect('/admin/user/student')


@route(r'/admin/logout/?',)
class LogoutHandler(BaseHandler):
    @asynchronous
    @gen.coroutine
    def get(self):
        del self.session['user']
        self.redirect('/admin/login')
